import * as types from '../actions/ActionTypes'
const initialState = {
	user:null,
	welcomed:false,
	entered:false,
	booted:false,
	logined:false,
	sliderLoop:false,	
	banners:[
		require('../static/Image/qidongtu.png'),
		
	]
}
export default appReducer = (state = initialState,action)=>{
	switch(action.type){
		case types.APP_BOOTED:
			return {
				...state,
				booted:true
			}
		case types.ENTER_LIDE:
			return {
				...state,
				entered:true
			}
		case types.WILL_ENTER_APP:
			let userData = action.payload.user
			let entered  = action.payload.entered
			let newState = {
				booted:true
			}
			if(entered && entered[1]==='yes'){
				newState.entered = true
			}
			if(userData && userData[1]){
				//有过登录行为
				let user = JSON.parse(userData[1])
				if(user && user.accessToken){
					newState.logined = true
					newState.user = user
				}
			}
			return {
				...state,
				...newState

			}
		default:
			return state
	}
}